package com.hnucm.ad0301;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;


public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private CircleView circleView;
    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.addBtn).setOnClickListener(this);
        findViewById(R.id.moveBtn).setOnClickListener(this);
        findViewById(R.id.clearBtn).setOnClickListener(this);

        circleView=findViewById(R.id.view);
    }
    @Override
    public void onClick(View view) {
        if(view.getId()==R.id.addBtn){
            Toast.makeText(MainActivity.this,"add",Toast.LENGTH_SHORT).show();
            circleView.addCircle();
        }else if(view.getId()==R.id.clearBtn){
            Toast.makeText(MainActivity.this,"clear",Toast.LENGTH_SHORT).show();
            circleView.clearCircle();
        }else if(view.getId()==R.id.moveBtn){
            Toast.makeText(MainActivity.this,"Move",Toast.LENGTH_SHORT).show();
            circleView.removeCircle();
        }
        //在子线程中重新执行一次
        circleView.postInvalidate();
    }
}